<template>
  <div id="lap-app">
    <div class="container">
      <div class="main">
        <el-form ref="form" :model="pFormData" status-icon class="user-login">
          <el-form-item
            prop="code"
            :rules="[{ required: true, message: '登录名不能为空' }]"
          >
            <el-input
              v-model="pFormData.code"
              placeholder="请输入登录名"
              size="medium"
              maxlength="50"
              prefix-icon="el-icon-user"
            ></el-input>
          </el-form-item>
          <el-form-item
            prop="pwd"
            :rules="[{ required: true, message: '密码不能为空' }]"
          >
            <el-input
              type="password"
              v-model="pFormData.pwd"
              placeholder="请输入密码"
              size="medium"
              maxlength="50"
              prefix-icon="el-icon-lock"
              @keyup.enter.native="doLogin"
            ></el-input>
          </el-form-item>
          <el-row :gutter="10">
            <el-col :span="12">
              <el-form-item>
                <el-button
                  type="primary"
                  @click="doLogin()"
                  size="medium"
                  style="width: 100%"
                  :loading="loading"
                  >登陆</el-button
                >
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "lap-app",
  data() {
    return {
      pFormData: {
        code: "",
        pwd: "",
      },
      loading: false,
    };
  },
  mounted() {
    const that = this;
  },
  methods: {
    /**
     * 登陆
     */
    doLogin() {
      const that = this;
      that.$refs["form"].validate((valid) => {
        if (valid) {
          $lap
            .post("/MLogXWeb/LogHandler.ashx", {
              type: "Login",
              code: Base64.encode(that.pFormData.code),
              pwd: Base64.encode(that.pFormData.pwd),
            })
            .then(function (data) {
              //本地数据
              $lap.cookie.set("token", data);
              window.loginToken = data;
              that.$router.push({
                path: "/Index",
              });
            });
        }
      });
    },
  },
  watch: {},
};
</script>

<style lang="scss" scoped>
html {
  height: 100% !important;
}
body {
  overflow: auto !important;
  background-color: #f0f2f5;
  height: 100%;
  padding: 0px;
  margin: 0px;
}
#lap-app {
  height: 100%;
  background-color: #f0f2f5;
  .container {
    background-color: #f0f2f5;
    position: relative;
    min-height: 700px;
    // height: 100%;
    padding: 110px 0px 140px;
  }
}
.top {
  text-align: center;
  .header {
    height: 44px;
    line-height: 44px;
    .title {
      font-size: 33px;
      color: rgba(0, 0, 0, 0.85);
      font-family: "Chinese Quote", -apple-system, BlinkMacSystemFont,
        "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
        "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji",
        "Segoe UI Emoji", "Segoe UI Symbol";
      font-weight: 600;
      position: relative;
      top: 2px;
    }
  }
  .desc {
    font-size: 14px;
    color: rgba(0, 0, 0, 0.45);
    margin-top: 12px;
    margin-bottom: 40px;
  }
}
.main {
  text-align: center;
  .user-login {
    width: 368px;
    margin: auto;
    text-align: left;
  }
}
.footer {
  position: absolute;
  width: 100%;
  bottom: 0px;
  margin: 48px 0 24px;
  text-align: center;
  line-height: 28px;
  font-size: 14px;
  .copyright {
    color: rgba(0, 0, 0, 0.45);
  }
}
</style>
